package com.poor.user.client.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.poor.user.client.configurer.UrlConfigurer;
import com.poor.user.client.model.request.PoorFilmPageRequestBean;
import com.poor.user.client.model.request.UserRequestBean;
import com.poor.user.client.model.response.PoorFilm;
import com.poor.user.client.service.FlimService;
import com.poor.user.client.service.UserService;
import com.poor.utils.RestTemplateUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Service
@Transactional
public class FilmServiceImpl implements FlimService {
    private RestTemplate restTemplate;

    @Override
    public List<PoorFilm> flimList(PoorFilmPageRequestBean poorFilmPageRequestBean) {
        String res = RestTemplateUtils.postForJson(UrlConfigurer.BASE_FILM_TEST_URL + "/list", JSONObject.toJSONString(poorFilmPageRequestBean));
        JSONObject jsonObject= JSON.parseObject(res);
        return JSONArray.parseArray(jsonObject.getString("data"),PoorFilm.class);
    }
}
